home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: in2.uu.net!bcstec!plato!hakuin!scott
- From: scott@hakuin.boeing.com (Scott Moody, 773-8600)
- Subject: Templates passing known classes?
- Message-ID: <Do9uKp.MM9@plato.ds.boeing.com>
- Sender: news@plato.ds.boeing.com
- Nntp-Posting-Host: hakuin
- Reply-To: scott@plato.ds.boeing.com
- Organization: Boeing Defense and Space Group
- Date: Thu, 14 Mar 1996 19:10:00 GMT
-
-
- I have a question about the Templates of C++.
- What I want to do is pass a class as a template parameter,
- but I want the class to be based on some type. I would then
- like to use methods from that type in the implementation of the class.
-
- eg.
-
- template <class polygons T>
- class stacks
- {
- T obj;
- .. then do things with obj like obj->circumference()
-
- }
-
- I should then be only able to instant stacks with something derrived from
- the polygons class (eg. squares, triangles). Not something like 'animals'.
- ---
-
- Second question:
- I want to inherit from multiple classes, but want the user to specify
- the classes as a parameter (really just like the template).
-
- eg.
-
- class stacks : <class polygons T>
- {
- }
-
- ----
- It seems these are important for 'adaptibility' of our programs.
-
- Thanks.
-
- scott moody
-